package com.content.scaffold.common.aspect;

import com.content.scaffold.common.event.BaseAsyncEvent;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author xiaojl
 */

@Aspect
@Component
public class EventPointcuts {

    @Pointcut("execution(* com.content.scaffold.common.event.listener*.*(..))")
    public void listener() {
    }

    @Before("listener() && args(event)")
    public void before(BaseAsyncEvent<Object> event) {
        event.loadRequestInfo();
    }

    @After("listener() && args(event)")
    public void after(BaseAsyncEvent<Object> event) {
        event.releaseRequestInfo();
    }
}
